﻿<UserControl x:Class="Unscrambler.Views.Gameboard"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:localViewModels="clr-namespace:Unscrambler.ViewModels;assembly=UnscramblerViewModels"
             xmlns:localControls="clr-namespace:Unscrambler.Controls"
             xmlns:localViews="clr-namespace:Unscrambler.Views"
             mc:Ignorable="d" 
             BorderBrush="Gray" BorderThickness="2"
             Height="Auto"
             Width="Auto"
             Margin="5,10,5,10"
             Name="gameboard"
             >
    <UserControl.Resources>
                
        <Style TargetType="{x:Type localViews:Gameboard}">
            <Setter Property="DataContext" Value="{Binding GameboardViewModel}"/>
            <Setter Property="Word" Value="{Binding Path=CurrentWord,Mode=OneWay}"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Source={StaticResource gameViewModel},Path=IsGameInProgress}" Value="True">
                    <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
                
                <DataTrigger Binding="{Binding Source={StaticResource gameViewModel},Path=AskIfUserWantsToExitCurrentGame}" Value="True">
                    <Setter Property="Visibility" Value="Collapsed"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding Source={StaticResource gameViewModel},Path=AskIfUserWantsToRestartCurrentGame}" Value="True">
                    <Setter Property="Visibility" Value="Collapsed"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding Source={StaticResource gameViewModel},Path=AskIfUserWantsToExitCurrentGame}" Value="False">
                    <!--<Setter Property="IsEnabled" Value="True"/>
                            <Setter Property="Opacity" Value="1"/>-->
                </DataTrigger>
                

            </Style.Triggers>
        </Style>
    </UserControl.Resources>
        <Grid>
        <Grid.Background>
            <ImageBrush ImageSource="..\Images\clipboard.jpg"  Stretch="UniformToFill"/>
        </Grid.Background>

            <Grid.RowDefinitions>
            <RowDefinition Height="50" Name="infoRow"/>
            <RowDefinition Height="Auto" Name="mainRow" />
                
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Row="0" DockPanel.Dock="Top" Orientation="Horizontal" Margin="5,0,5,0">
            <StackPanel.Resources>
                <Style TargetType="{x:Type TextBlock}">
                    <Setter Property="FontSize" Value="20"/>
                    <Setter Property="FontWeight" Value="DemiBold"/>
                    <Setter Property="VerticalAlignment" Value="Center"/>
                    <Setter Property="Margin" Value="10,0,0,0"/>
                    
                </Style>
            </StackPanel.Resources>
            <TextBlock Text="Your Answer:" />
            <TextBlock Text="{Binding ElementName=answerCanvas,Path=CurrentAnswer}" Width="250"/>
            <TextBlock Text="Hint:" />
            <TextBlock Text="{Binding Path=HintWord}"  Width="250"/>
            <TextBlock Text="Time:" />
            <TextBlock Text="{Binding Path=ElapsedTime}"   Width="80"   />
            
        </StackPanel>

        <localViews:CorrectWordView Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>

        <localViews:GameOverView Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
        <Canvas x:Name="scrambleCanvas" Grid.Row="1" DockPanel.Dock="Top" 
                
                HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            
            <Canvas.Style>
                <Style TargetType="{x:Type Canvas}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=answerCanvas,Path=IsCorrect}" Value="True">
                            <Setter Property="Visibility" Value="Collapsed"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding ElementName=answerCanvas,Path=IsCorrect}" Value="False">
                            <Setter Property="Visibility" Value="Visible"/>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=IsGameOver}" Value="True">
                            <Setter Property="Visibility" Value="Collapsed"/>
                        </DataTrigger>

                    </Style.Triggers>
                </Style>
            </Canvas.Style>
            <localControls:AnswerCanvas x:Name="answerCanvas"
                                        Margin="0,0,0,0"
                                        Canvas.Top="0" Canvas.Left="0"
                                        Height="199" Width="{Binding ElementName=scrambleCanvas,Path=ActualWidth}"
                                        Word="{Binding Path=CurrentWord,Mode=OneWay}">
                <localControls:AnswerCanvas.Background>
                    <ImageBrush ImageSource="..\Images\blackboard.jpg" Stretch="UniformToFill"/>
                </localControls:AnswerCanvas.Background>

            </localControls:AnswerCanvas>
        </Canvas>



    </Grid>
</UserControl>
